```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Java线程方法start()与run()深度解析</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            color: #333;
            line-height: 1.8;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #6e8efb 0%, #a777e3 100%);
        }
        .code-block {
            background-color: #282c34;
            border-radius: 8px;
            box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
        }
        .feature-card {
            transition: all 0.3s ease;
            border-radius: 12px;
            overflow: hidden;
        }
        .feature-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        }
        .comparison-table {
            border-collapse: separate;
            border-spacing: 0;
            width: 100%;
            overflow: hidden;
            border-radius: 12px;
            box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
        }
        .comparison-table th {
            background-color: #4f46e5;
            color: white;
            font-weight: 600;
            padding: 16px;
            text-align: center;
        }
        .comparison-table td {
            padding: 16px;
            border: 1px solid #e5e7eb;
            text-align: center;
        }
        .comparison-table tr:nth-child(odd) td {
            background-color: #f9fafb;
        }
        .comparison-table tr:nth-child(even) td {
            background-color: white;
        }
        .highlight-text {
            position: relative;
            display: inline-block;
        }
        .highlight-text::after {
            content: '';
            position: absolute;
            bottom: 0;
            left: 0;
            width: 100%;
            height: 30%;
            background-color: rgba(79, 70, 229, 0.2);
            z-index: -1;
            transition: all 0.3s ease;
        }
        .highlight-text:hover::after {
            height: 40%;
            background-color: rgba(79, 70, 229, 0.3);
        }
        .divider {
            display: flex;
            align-items: center;
            margin: 32px 0;
        }
        .divider::before, .divider::after {
            content: "";
            flex: 1;
            border-bottom: 1px solid #e5e7eb;
        }
        .divider-text {
            padding: 0 16px;
            color: #6b7280;
            font-size: 0.875rem;
            font-weight: 500;
        }
        .mermaid {
            background-color: white;
            border-radius: 12px;
            padding: 24px;
            box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
            margin: 24px 0;
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <div class="hero-gradient text-white py-20 px-4 sm:px-6 lg:px-8">
        <div class="max-w-4xl mx-auto text-center">
            <h1 class="text-4xl md:text-5xl font-bold mb-6 font-serif">深入理解Java线程 <span class="text-yellow-300">start()</span> 与 <span class="text-green-300">run()</span></h1>
            <p class="text-xl md:text-2xl opacity-90 mb-8 max-w-3xl mx-auto">解锁多线程编程的核心概念，掌握并发执行的精髓</p>
            <div class="flex justify-center space-x-4">
                <a href="#start" class="bg-white text-indigo-600 hover:bg-indigo-100 px-6 py-3 rounded-lg font-medium transition duration-300 shadow-lg">
                    <i class="fas fa-play-circle mr-2"></i>start()方法
                </a>
                <a href="#run" class="bg-indigo-700 text-white hover:bg-indigo-800 px-6 py-3 rounded-lg font-medium transition duration-300 shadow-lg">
                    <i class="fas fa-running mr-2"></i>run()方法
                </a>
            </div>
        </div>
    </div>

    <!-- Main Content -->
    <div class="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 py-16">
        <!-- Introduction -->
        <div class="mb-16">
            <p class="text-lg text-gray-700 mb-8 leading-relaxed">
                <span class="text-3xl font-serif font-bold text-indigo-600 float-left mr-3 -mt-1">J</span>
                <span class="highlight-text">ava线程模型</span>是现代并发编程的基石，而<code class="bg-indigo-100 text-indigo-700 px-2 py-1 rounded">start()</code>和<code class="bg-green-100 text-green-700 px-2 py-1 rounded">run()</code>方法是理解多线程运行机制的关键。本文将深入剖析这两个方法的区别、使用场景以及最佳实践，帮助开发者避免常见的多线程陷阱。
            </p>
            
            <div class="mermaid">
                flowchart TD
                    A[主线程] --> B[start()方法]
                    B --> C[创建新线程]
                    C --> D[分配线程栈]
                    D --> E[可运行状态]
                    E --> F[run()方法执行]
                    A --> G[直接调用run()]
                    G --> H[当前线程同步执行]
            </div>
        </div>

        <!-- Start Method Section -->
        <section id="start" class="mb-20">
            <div class="flex items-center mb-8">
                <div class="bg-indigo-600 text-white p-3 rounded-lg mr-4 shadow-lg">
                    <i class="fas fa-play-circle text-2xl"></i>
                </div>
                <h2 class="text-3xl font-bold text-gray-800 font-serif">1. <code class="text-indigo-600">start()</code> 方法解析</h2>
            </div>
            
            <div class="bg-white rounded-xl shadow-md overflow-hidden mb-8 feature-card">
                <div class="p-6 md:p-8">
                    <p class="text-gray-700 mb-6"><code class="bg-indigo-100 text-indigo-700 px-2 py-1 rounded">start()</code> 方法是Java线程类中最核心的方法之一，它的主要功能是启动一个新线程。调用<code class="bg-indigo-100 text-indigo-700 px-2 py-1 rounded">start()</code>后，JVM会为该线程创建一个新的线程栈，并将其置于可运行状态。然后，线程调度器会选择合适的时间来执行该线程。一旦线程启动，<code class="bg-indigo-100 text-indigo-700 px-2 py-1 rounded">start()</code>方法会调用线程的<code class="bg-green-100 text-green-700 px-2 py-1 rounded">run()</code>方法。</p>
                    
                    <h3 class="text-xl font-semibold text-gray-800 mb-4 flex items-center">
                        <i class="fas fa-key mr-2 text-indigo-500"></i> 关键特性
                    </h3>
                    <ul class="space-y-3 mb-6">
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span><strong class="text-indigo-700">多线程运行</strong>：<code class="bg-indigo-100 text-indigo-700 px-1 py-0.5 rounded">start()</code>方法确保线程是并发运行的，即与调用线程并行执行。</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-exclamation-triangle text-yellow-500 mt-1 mr-2"></i>
                            <span><strong class="text-indigo-700">调用限制</strong>：<code class="bg-indigo-100 text-indigo-700 px-1 py-0.5 rounded">start()</code>方法只能被调用一次，多次调用会抛出<code class="bg-red-100 text-red-700 px-1 py-0.5 rounded">IllegalThreadStateException</code>异常。</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-code-branch text-purple-500 mt-1 mr-2"></i>
                            <span><strong class="text-indigo-700">独立上下文</strong>：每个线程拥有独立的执行上下文，互不干扰。</span>
                        </li>
                    </ul>
                    
                    <div class="code-block text-sm md:text-base overflow-x-auto p-4 mb-6">
                        <pre class="text-gray-200"><code>public class MyThread extends Thread {
    @Override
    public void run() {
        System.out.println("线程正在运行");
    }
}

public class Main {
    public static void main(String[] args) {
        MyThread thread = new MyThread();
        thread.start();  // 启动新线程，并调用run()方法
    }
}</code></pre>
                    </div>
                    
                    <div class="bg-blue-50 border-l-4 border-blue-500 p-4 mb-6">
                        <div class="flex">
                            <div class="flex-shrink-0">
                                <i class="fas fa-info-circle text-blue-500 text-xl mt-1 mr-3"></i>
                            </div>
                            <div>
                                <p class="text-blue-800"><strong>专业提示：</strong> 使用<code class="bg-blue-100 text-blue-700 px-1 py-0.5 rounded">start()</code>方法时，线程的执行顺序是不确定的，由线程调度器决定。这是多线程编程与单线程编程的重要区别。</p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Run Method Section -->
        <section id="run" class="mb-20">
            <div class="flex items-center mb-8">
                <div class="bg-green-600 text-white p-3 rounded-lg mr-4 shadow-lg">
                    <i class="fas fa-running text-2xl"></i>
                </div>
                <h2 class="text-3xl font-bold text-gray-800 font-serif">2. <code class="text-green-600">run()</code> 方法解析</h2>
            </div>
            
            <div class="bg-white rounded-xl shadow-md overflow-hidden mb-8 feature-card">
                <div class="p-6 md:p-8">
                    <p class="text-gray-700 mb-6"><code class="bg-green-100 text-green-700 px-2 py-1 rounded">run()</code>方法是线程执行的具体内容。通常，我们会重写<code class="bg-green-100 text-green-700 px-2 py-1 rounded">run()</code>方法来定义线程在运行期间要执行的任务。<code class="bg-green-100 text-green-700 px-2 py-1 rounded">run()</code>方法本身并不会启动新线程，它只是一个普通的方法调用。如果直接调用<code class="bg-green-100 text-green-700 px-2 py-1 rounded">run()</code>方法，它将在调用线程的上下文中同步执行，而不会启动新线程。</p>
                    
                    <h3 class="text-xl font-semibold text-gray-800 mb-4 flex items-center">
                        <i class="fas fa-key mr-2 text-green-500"></i> 关键特性
                    </h3>
                    <ul class="space-y-3 mb-6">
                        <li class="flex items-start">
                            <i class="fas fa-sort-amount-down text-blue-500 mt-1 mr-2"></i>
                            <span><strong class="text-green-700">顺序执行</strong>：如果直接调用<code class="bg-green-100 text-green-700 px-1 py-0.5 rounded">run()</code>，它不会创建新线程，任务将在当前线程中顺序执行。</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-redo text-purple-500 mt-1 mr-2"></i>
                            <span><strong class="text-green-700">可多次调用</strong>：<code class="bg-green-100 text-green-700 px-1 py-0.5 rounded">run()</code>方法可以被多次调用，因为它是普通的方法调用，没有线程状态的约束。</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-project-diagram text-indigo-500 mt-1 mr-2"></i>
                            <span><strong class="text-green-700">同步执行</strong>：在调用<code class="bg-green-100 text-green-700 px-1 py-0.5 rounded">run()</code>方法的线程上下文中运行。</span>
                        </li>
                    </ul>
                    
                    <div class="code-block text-sm md:text-base overflow-x-auto p-4 mb-6">
                        <pre class="text-gray-200"><code>public class MyThread extends Thread {
    @Override
    public void run() {
        System.out.println("线程正在运行");
    }
}

public class Main {
    public static void main(String[] args) {
        MyThread thread = new MyThread();
        thread.run();  // 直接调用run()方法，不会启动新线程
    }
}</code></pre>
                    </div>
                    
                    <div class="bg-yellow-50 border-l-4 border-yellow-500 p-4 mb-6">
                        <div class="flex">
                            <div class="flex-shrink-0">
                                <i class="fas fa-exclamation-triangle text-yellow-500 text-xl mt-1 mr-3"></i>
                            </div>
                            <div>
                                <p class="text-yellow-800"><strong>常见误区：</strong> 许多初学者会错误地直接调用<code class="bg-yellow-100 text-yellow-700 px-1 py-0.5 rounded">run()</code>方法，期望它能创建新线程。实际上，这只会导致代码在当前线程中同步执行，失去了多线程的意义。</p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Comparison Section -->
        <section class="mb-20">
            <div class="divider">
                <span class="divider-text bg-gray-50 rounded-full px-4 py-2 shadow-sm">
                    <i class="fas fa-balance-scale mr-2"></i>对比分析
                </span>
            </div>
            
            <h2 class="text-3xl font-bold text-gray-800 mb-8 text-center font-serif"><code class="text-indigo-600">start()</code> 与 <code class="text-green-600">run()</code> 方法对比</h2>
            
            <div class="overflow-x-auto">
                <table class="comparison-table">
                    <thead>
                        <tr>
                            <th>特性</th>
                            <th><code>start()</code></th>
                            <th><code>run()</code></th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td class="font-medium text-gray-700">线程启动</td>
                            <td class="text-indigo-600 font-medium">是的，启动一个新线程</td>
                            <td class="text-green-600 font-medium">否，不会启动新线程</td>
                        </tr>
                        <tr>
                            <td class="font-medium text-gray-700">线程并发</td>
                            <td class="text-indigo-600 font-medium">是的，与调用线程并发运行</td>
                            <td class="text-green-600 font-medium">否，在当前线程中顺序执行</td>
                        </tr>
                        <tr>
                            <td class="font-medium text-gray-700">调用次数</td>
                            <td class="text-indigo-600 font-medium">只能调用一次，否则抛出异常</td>
                            <td class="text-green-600 font-medium">可以多次调用，像普通方法一样</td>
                        </tr>
                        <tr>
                            <td class="font-medium text-gray-700">执行位置</td>
                            <td class="text-indigo-600 font-medium">在线程的独立执行上下文中运行</td>
                            <td class="text-green-600 font-medium">在调用run()方法的线程上下文中运行</td>
                        </tr>
                        <tr>
                            <td class="font-medium text-gray-700">典型用途</td>
                            <td class="text-indigo-600 font-medium">实现真正的多线程并发</td>
                            <td class="text-green-600 font-medium">测试线程逻辑或同步执行</td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </section>

        <!-- Best Practices -->
        <section class="mb-20">
            <div class="flex items-center mb-8">
                <div class="bg-purple-600 text-white p-3 rounded-lg mr-4 shadow-lg">
                    <i class="fas fa-graduation-cap text-2xl"></i>
                </div>
                <h2 class="text-3xl font-bold text-gray-800 font-serif">3. 最佳实践指南</h2>
            </div>
            
            <div class="grid md:grid-cols-2 gap-6">
                <div class="bg-white rounded-xl shadow-md overflow-hidden feature-card">
                    <div class="p-6 md:p-8">
                        <div class="flex items-center mb-4">
                            <div class="bg-indigo-100 text-indigo-600 p-2 rounded-lg mr-3">
                                <i class="fas fa-check-circle text-lg"></i>
                            </div>
                            <h3 class="text-xl font-semibold text-gray-800">启动线程的正确方式</h3>
                        </div>
                        <p class="text-gray-700 mb-4">如果需要在多线程环境中并发执行任务，应该使用<code class="bg-indigo-100 text-indigo-700 px-1 py-0.5 rounded">start()</code>方法。这确保任务在一个新线程中并发执行，而不是阻塞主线程或调用线程。</p>
                        <div class="code-block text-sm overflow-x-auto p-4">
                            <pre class="text-gray-200"><code>MyThread thread = new MyThread();
thread.start(); // 正确：启动新线程</code></pre>
                        </div>
                    </div>
                </div>
                
                <div class="bg-white rounded-xl shadow-md overflow-hidden feature-card">
                    <div class="p-6 md:p-8">
                        <div class="flex items-center mb-4">
                            <div class="bg-red-100 text-red-600 p-2 rounded-lg mr-3">
                                <i class="fas fa-exclamation-triangle text-lg"></i>
                            </div>
                            <h3 class="text-xl font-semibold text-gray-800">避免的错误做法</h3>
                        </div>
                        <p class="text-gray-700 mb-4">直接调用<code class="bg-green-100 text-green-700 px-1 py-0.5 rounded">run()</code>可能会导致误解，因为它不会创建新线程。只在测试<code class="bg-green-100 text-green-700 px-1 py-0.5 rounded">run()</code>方法逻辑时直接调用。</p>
                        <div class="code-block text-sm overflow-x-auto p-4">
                            <pre class="text-gray-200"><code>MyThread thread = new MyThread();
thread.run(); // 错误：不会创建新线程</code></pre>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Example Comparison -->
        <section class="mb-20">
            <h2 class="text-3xl font-bold text-gray-800 mb-8 text-center font-serif">4. 实例对比分析</h2>
            
            <div class="grid md:grid-cols-2 gap-8">
                <div>
                    <div class="flex items-center mb-4">
                        <div class="bg-indigo-600 text-white p-2 rounded-lg mr-3">
                            <i class="fas fa-bolt text-lg"></i>
                        </div>
                        <h3 class="text-xl font-semibold text-gray-800">使用<code class="text-indigo-600">start()</code>方法的多线程示例</h3>
                    </div>
                    
                    <div class="code-block text-sm overflow-x-auto p-4 mb-4">
                        <pre class="text-gray-200"><code>public class MyThread extends Thread {
    @Override
    public void run() {
        System.out.println("线程名：" + Thread.currentThread().getName());
    }
}

public class Main {
    public static void main(String[] args) {
        MyThread thread1 = new MyThread();
        MyThread thread2 = new MyThread();
        thread1.start();  // 启动thread1新线程
        thread2.start();  // 启动thread2新线程
    }
}</code></pre>
                    </div>
                    
                    <div class="bg-indigo-50 border-l-4 border-indigo-500 p-4">
                        <p class="text-indigo-800"><i class="fas fa-info-circle mr-2"></i>在这个例子中，<code class="bg-indigo-100 text-indigo-700 px-1 py-0.5 rounded">thread1</code>和<code class="bg-indigo-100 text-indigo-700 px-1 py-0.5 rounded">thread2</code>是并发运行的，输出顺序不固定，由线程调度器决定。</p>
                    </div>
                </div>
                
                <div>
                    <div class="flex items-center mb-4">
                        <div class="bg-green-600 text-white p-2 rounded-lg mr-3">
                            <i class="fas fa-sort-amount-down text-lg"></i>
                        </div>
                        <h3 class="text-xl font-semibold text-gray-800">直接调用<code class="text-green-600">run()</code>方法的顺序执行示例</h3>
                    </div>
                    
                    <div class="code-block text-sm overflow-x-auto p-4 mb-4">
                        <pre class="text-gray-200"><code>public class MyThread extends Thread {
    @Override
    public void run() {
        System.out.println("线程名：" + Thread.currentThread().getName());
    }
}

public class Main {
    public static void main(String[] args) {
        MyThread thread1 = new MyThread();
        MyThread thread2 = new MyThread();
        thread1.run();  // 在主线程中顺序调用
        thread2.run();  // 依旧在主线程中顺序调用
    }
}</code></pre>
                    </div>
                    
                    <div class="bg-green-50 border-l-4 border-green-500 p-4">
                        <p class="text-green-800"><i class="fas fa-info-circle mr-2"></i>在这个例子中，<code class="bg-green-100 text-green-700 px-1 py-0.5 rounded">thread1</code>和<code class="bg-green-100 text-green-700 px-1 py-0.5 rounded">thread2</code>的<code class="bg-green-100 text-green-700 px-1 py-0.5 rounded">run()</code>方法在主线程中顺序执行，结果输出的顺序是固定的。</p>
                    </div>
                </div>
            </div>
        </section>
    </div>

    <!-- Footer -->
    <footer class="bg-gray-900 text-gray-300 py-12 px-4">
        <div class="max-w-4xl mx-auto">
            <div class="flex flex-col md:flex-row justify-between items-center">
                <div class="mb-6 md:mb-0">
                    <h3 class="text-xl font-bold text-white mb-2">技术小馆</h3>
                    <p class="text-gray-400">专业的编程技术分享平台</p>
                </div>
                <div>
                    <a href="http://www.yuque.com/jtostring" class="text-gray-300 hover:text-white transition duration-300 flex items-center">
                        <i class="fas fa-external-link-alt mr-2"></i>
                        <span>访问语雀主页</span>
                    </a>
                </div>
            </div>
            <div class="border-t border-gray-800 mt-8 pt-8 text-center text-sm text-gray-500">
                &copy; 2023 技术小馆. 保留所有权利.
            </div>
        </div>
    </footer>

    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            }
        });
    </script>
</body>
</html>
```